let peopleMessage=document.getElementsByClassName("peopleMessage")[0];
document.addEventListener('scroll',function(){
    let topJuLi = document.documentElement.scrollTop;
    peopleMessage.style.top = topJuLi+"px";
},true);
/*点赞*/
let lickCollectionComment=document.getElementsByClassName("lickCollectionComment")[0];
let readContain=document.getElementsByClassName("readContain")[0];
Top();
window.onresize = function(){
    Top();
}
document.onscroll=function(){
    Top();
}
function Top(){
    if(readContain.offsetHeight>document.documentElement.scrollTop+document.documentElement.clientHeight){
        lickCollectionComment.style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-125)+"px";
    }else{
        lickCollectionComment.style.top="";
    }
}
let lickB=document.getElementsByClassName("lickB");
let commentInputContent=document.getElementsByClassName("commentInputContent")[0];
lickB[2].onclick=function(){
    returnPositionX(commentInputContent.offsetTop-document.documentElement.clientHeight+120);
}
function returnPositionX(e) {
    let backTopTimer = setInterval(function() {
        let topH = document.documentElement.scrollTop || document.body.scrollTop;
        if(topH < e) {
            document.documentElement.scrollTop = document.body.scrollTop = topH +30;
        }else{
            clearInterval(backTopTimer);
        }
    }, 10);
}
let commentBtn=document.getElementsByClassName("commentBtn")[0]
let commentInput=document.getElementsByClassName("commentInput")[0];
commentBtn.style.backgroundColor="#ccccd7";
commentInput.oninput=function(){
    if(commentInput.value==""){
        commentBtn.style.backgroundColor="#ccccd7";
    }else{
        commentBtn.style.backgroundColor="#42bbfd";
        commentBtn.onclick=function(){
            let strContent =commentInput.value;
            strContent = strContent.replace(/\r\n/g, '<br/>'); //IE9、FF、chrome
            strContent = strContent.replace(/\n/g, '<br/>'); //IE7-8
            strContent = strContent.replace(/\s/g, '&nbsp;'); //空格处理
            console.log(strContent)
        }
    }
}
let BlogId=document.getElementsByClassName("BlogId")[0];
let lick=document.getElementsByClassName("lick");
lickB[0].onclick=function(){
    /*点赞*/
    D();
}
lickB[1].onclick=function(){
    /*收藏*/
    S();
}
/*点赞*/
function D(){
    $.ajax({
        url:"../thumbsUp/ThumbsUp",
        data:{
            blogid:BlogId.innerHTML,
            userid:sessionStorage.getItem("id")
        },
        success:function(data){
            location.reload();
        }
    });
}
/*收藏*/
function S(){
    $.ajax({
        url:"../collection/Collection",
        data:{
            blogid:BlogId.innerHTML,
            userid:sessionStorage.getItem("id")
        },
        success:function(data){
            location.reload();
        }
    });
}

